package cn.laixueit.service.impl;

import cn.laixueit.mapper.UsersMapper;
import cn.laixueit.pojo.Users;
import cn.laixueit.pojo.UsersExample;
import cn.laixueit.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

import java.util.List;

@Service
public class UsersServiceImpl implements UserService {

    @Autowired
    private UsersMapper usersMapper;

    @Override
    public Boolean login(Users users) {
        UsersExample example = new UsersExample();
        UsersExample.Criteria criteria = example.createCriteria();
        criteria.andUsernameEqualTo(users.getUsername()).andPasswordEqualTo(DigestUtils.md5DigestAsHex(users.getPassword().getBytes()));
        List<Users> usersList = usersMapper.selectByExample(example);
        if(usersList.size()>0){
            return  true;
        }
        return false;
    }
}
